<#include "/common/easyui-css.html">
<#include "/common/easyui-js.html">
<#include "/common/loading.html">
<script type="text/javascript" src="/lib/layer/2.4/layer.js"></script>

<body class="easyui-layout">
<!-- 说明 字符串：Material，作为替换字符串 -->
<div class="easyui-layout" style="width:100%;height:100%;">
    <!-- 主表  -->
    <table id="in_table" class="easyui-datagrid" title="" style="width:100%;height:100%;padding-bottom: 2px;"
           data-options="rownumbers:true, pagination:false,singleSelect:true,url:'/report-list/IN/yd',
					  method:'get',
					  fitColumns : true,

					  toolbar:'#tb',
					  loadMsg : '数据加载中',
					  showFooter: true" >
        <thead>
        <th data-options="field:'material',width:200,align:'center' ">物资</th>
        <th data-options="field:'supplier',width:200,align:'center' ">供货单位</th>
        <th data-options="field:'cars',width:200,align:'center' ">车数</th>
        <th data-options="field:'dialy',width:200,align:'center' ">数量</th>
        <th data-options="field:'allgross',width:200,align:'center' ">厂家累计</th>
        <th data-options="field:'daysuttle',width:200,align:'center' ">单日累积</th>
        <th data-options="field:'allsuttle',width:200,align:'center' ">总累计</th>
        </thead>
    </table>
</div>

<!-- 搜索框 -->
<div id="tb" style="padding:5px;height:auto">
    <div>
        <input class="easyui-datebox" data-options="formatter:dateformatter,parser:dateparser" id="from" style="width:200px">
        <#--结束时间：<input class="easyui-datetimebox" data-options="formatter:dateformatter,parser:dateparser" id="to" style="width:200px">-->
        <a href="#" class="easyui-linkbutton" iconCls="icon-search" id="searchByParameter">搜索</a>
    </div>
    <div style="margin:5px 0;"></div>
    <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-download'"  id="export">下载</a>
</div>

<!-- 按钮操作 -->
<script type="text/javascript">

    function dateformatter(date){
        var y = date.getFullYear();
        var m = date.getMonth()+1;
        var d = date.getDate();
        return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d);
        // var hor = date.getHours();
        // var min = date.getMinutes();
        // var sec = date.getSeconds();
        // return y+'-'+(m<10?('0'+m):m)+'-'+(d<10?('0'+d):d+' '+(hor<10?('0'+hor):hor)+':'+(min<10?('0'+min):min)+':'+(sec<10?('0'+sec):sec));
    }
    function dateparser(s){
        if (!s) return new Date();
        var ss = (s.split('-'));
        var y = parseInt(ss[0],10);
        var m = parseInt(ss[1],10);
        var d = parseInt(ss[2],10);
        if (!isNaN(y) && !isNaN(m) && !isNaN(d)){
            return new Date(y,m-1,d);
        } else {
            return new Date();
        }
        // if (!s) return new Date();
        // var hfm = (s.split(' '))[1];
        // var ss = (s.split('-'));
        // var y = parseInt(ss[0],10);
        // var m = parseInt(ss[1],10);
        // var d = parseInt(ss[2],10);
        // var hour = parseInt(hfm.split(':')[0]);
        // var min = parseInt(hfm.split(':')[1]);
        // var sec = parseInt(hfm.split(':')[2]);
        // if (!isNaN(y) && !isNaN(m) && !isNaN(d)&&!isNaN(hour) && !isNaN(min) && !isNaN(sec)){
        //     return new Date(y,m-1,d,hour,min,sec);
        // } else {
        //     return new Date();
        // }
    }
    $('#export').click(function(){
        var from = $('#from').val();
        if(from==''||from=='undefined'){
            layer.msg("请选择开始时间");
            return false;
        }
        window.location = "/daily-download/IN/yd?from="+from;

    });
    $('#searchByParameter').click(function () {
        var date = $('#from').val();
        var toDate = $('#to').val();
        var handler = '/report-list/IN/yd?date='+date;
        // window.location = "/daily-download/IN/yd?date="+date;
        $('#in_table').datagrid('options').url = handler;
        $('#in_table').datagrid('reload');

    })
</script>

